package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.repository.entity.Comment;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import com.dragon.common.util.BeanUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Date;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class CommentVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "用户id")
    private Integer adminId;

    @ApiModelProperty(value = "主表id")
    private Integer correlationId;

    @ApiModelProperty(value = "父级评论id")
    private Integer parentId;

    @ApiModelProperty(value = "内容")
    private String replyText;

    @ApiModelProperty(value = "被回复的用户id")
    private Integer replyAdminId;

    @ApiModelProperty(value = "流程类型 跟进记录7 日报26")
    private Integer streamType;

    @ApiModelProperty(value = "评论时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "被回复的怕评论id")
    private Integer replyId;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static Comment convert(CommentVO vo) {
        Comment entity = new Comment();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<Comment> convertList(List<CommentVO> list) {
        List<Comment> resultList = new ArrayList<>();
        for (CommentVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
